Component({
  data: {
    selected: 0,
    color: "#aaaaaa",
    selectedColor: "#FFFFFF",
    backgroundColor: "#FFFFFF",
    backgroundColorSelected: "#363FB5",
    list: [
      {
        pagePath: "/pages/tabs/home/home",
        iconPath: "/assets/tabIcons/home.png",
        selectedIconPath: "/assets/tabIcons/home-active.png",
        text: "Home",
      },
      {
        pagePath: "/pages/tabs/explore/explore",
        iconPath: "/assets/tabIcons/explore.png",
        selectedIconPath: "/assets/tabIcons/explore-active.png",
        text: "Explore"
      },
      {
        pagePath: "/pages/tabs/profile/profile",
        iconPath: "/assets/tabIcons/profile.png",
        selectedIconPath: "/assets/tabIcons/profile-active.png",
        text: "Profile"
      }
    ]
  },
  attached() {
    var that=this
    wx.getStorage({
      key: 'select_index',
      success(res)
      {
        console.log("存在")
        that.setData({
          selected:res.data
        })
      },fail(err)
      {
        console.log("不存在")
      }
    })
  },
  methods: {
    switchTab(e) {
      const data = e.currentTarget.dataset
      const url = data.path
     wx.switchTab({
       url: url,
     })
      // this.setData({
      //   selected: data.index
      // })
    
      wx.setStorage({
        data: data.index,
        key: 'select_index',
      })

    }
  }
})